/**
 options - system config class
 
 $Id: options.h 2 2012-04-04 15:07:32Z gerhardus1@gmail.com $
 Versioning: a.b.c a is a major release, b represents changes or new features, c represents bug fixes. 
 @version 1.0.0   06/10/2011    Gerhardus Muller     Script created

 @note

 @todo
 
 @bug

 Copyright Gerhardus Muller
 */

#if !defined( options_defined_ )
#define options_defined_

#include "../logging/logger.h"
#include <boost/program_options.hpp>
namespace po = boost::program_options;

class options
{
  // Definitions
  public:
    static const int DEF_OUTPUT_WIDTH = 100;
    static const char* APP_BASE_NAME;

    // Methods
  public:
    options( );
    virtual ~options();
    virtual std::string toString ();
    po::variables_map& getVariableMap( )  { return vm; }
    bool parseOptions( int ac, char* av[] );
    void logOptions( );
    bool bGetBDaemon( )                   { return bDaemon; }

  protected:

  private:
    std::string displayOptions( );

    // Properties
  public:
    int                         argc;                     ///< original argc;
    char**                      argv;                     ///< original argv
    std::string                 logFile;                  ///< full path to the log file
    bool                        bLogConsole;              ///< true to log to the console
    bool                        bLogStderr;               ///< 1 to log on the console (stderr), 0 if not
    bool                        bFlushLogs;               ///< true to flush after each write
    bool                        bDaemon;                  ///< run as a daemon
    int                         defaultLogLevel;          ///< defaultLogLevel
    unsigned int                maintInterval;            ///< timer interval used for maintenance, this includes event expiration, max exec times and the delay queue
    unsigned int                statsInterval;            ///< stats interval in seconds
    unsigned int                expiredEventInterval;     ///< interval in seconds between checks for expired events in the queue

    // main config
    std::string                 statsUrl;                 ///< url for stats reporting
    std::string                 runAsUser;                ///< user to run as
    std::string                 logGroup;                 ///< group for log file creation
    std::string                 baseDir;                  ///< base directory for server
    std::string                 logBaseDir;               ///< base directory for server
    std::string                 configFile;               ///< config file to use
    std::string                 pidName;                  ///< name of the pid file to use
    std::string                 defaultQueue;             ///< default queue for event processing

    // socket class requirements
    std::string                 packetSuccessReply;       ///< reply written on a socket as a result of processing (dispatching) successfully - set to empty to disable
    std::string                 packetFailReply;          ///< reply written on a socket as a result of failing to process (dispatch) successfully - typically not deserialised properly - set to empty to disable

  protected:
    logger&                     log;                      ///< class scope logger

  private:
    po::variables_map           vm;                       ///< variable map holding all config options
};	// class options

extern options* pOptions;

#endif // !defined( options_defined_)

